#include <iostream>
#include <math.h>
#include <string.h>
#include <map>
//#pragma GCC optimize(3,"Ofast","inline")
using namespace std;
const int inf=0x7fffffff;

struct motion{
	int up,down;
};


struct pipeline{
	int ceiling,floor;
	bool have_pipeline=false;
};


//bool cmp(pipeline a,pipeline b){
//	return a.location<b.location;
//}


int main(){
	int n,m,k,ans=inf,go_pass=0;
	bool can_pass;
	scanf("%d%d%d",&n,&m,&k);
	motion a[n];
	map<int,pipeline> b;
	int dp1[m+1],dp2[m+1];
	memset(dp1,0,sizeof(dp1));
	for(int i=0;i<n;i++)
		scanf("%d%d",&a[i].up,&a[i].down);
	for(int i=0;i<k;i++){
		int index;
		scanf("%d",&index);
		scanf("%d%d",&b[index].floor,&b[index].ceiling);
		b[index].have_pipeline = true;
//		scanf("%d%d%d",&b[i].location,&b[i].floor,&b[i].ceiling);
///		cin>>b[i].location>>b[i].floor>>b[i].ceiling;
	}
//	sort(b,b+k,cmp);
//	int index=0;
	for(int i=1;i<=n;i++){
		can_pass = false;
//		bool have_pipeline=false;
		for(int j=1;j<=m;j++){
			if(b[i].have_pipeline  &&  (j <= b[i].floor  ||  j >= b[i].ceiling)){
					dp2[j] = inf;
//					have_pipeline = true;
					continue;
//				have_pipeline = true;
			}
			if(j == m){
				dp2[j] = dp1[j]+1;
				for(int k=(b[i-1].have_pipeline?b[i-1].ceiling-1:m-1);k>(b[i].have_pipeline?b[i-1].floor:0);k--)
					dp2[j] = min(dp2[j]+0.0,dp1[k]==inf?inf:dp1[k]+ceil((j-k+0.0)/a[i-1].up));
			}
			else{
				dp2[j] = j+a[i-1].down>m?inf:dp1[j+a[i-1].down];
				for(int k=j-a[i-1].up;k>(b[i-1].have_pipeline?b[i-1].floor:0);k-=a[i-1].up)
					dp2[j] = min(dp2[j],dp1[k]!=inf?dp1[k]+(j-k)/a[i-1].up:inf);
			}
//			if(dp2[j] < 0)
//				cout<<i<<endl<<endl;
			if(dp2[j] != inf)
				can_pass = true;
		}
		if(!can_pass){
			cout<<0<<endl;
			cout<<go_pass;
			return 0;
		}
		if(b[i].have_pipeline)
			go_pass++;
		memcpy(dp1,dp2,sizeof(dp1));
	}
	cout<<1<<endl;
	for(int i=1;i<=m;i++)
		ans = min(ans,dp1[i]);
	cout<<ans;
	return 0;
}
